<?php

class Back_Form_Droits extends Jnd_Form
{

    private $_ressources = array();
    private $_roles = array();

    public function __construct ($decorateur = "Formulairejndpro", $options = null)
    {
        if (isset($options["ressources"])) {
            $this->_ressources = $options['ressources'];
            unset($options['ressources']);
        }
        if (isset($options["roles"])) {
            $this->_roles = $options['roles'];
            unset($options['roles']);
        }
        parent::__construct($decorateur, $options);
        $this->setElementDecorators(
                array(
                        "$decorateur"
                ), array(), false);
    }

    public function init ()
    {
        $this->setAction('/back/droits/editer');
        $this->setName("droits");
        $this->setMethod("post");
        $this->addAttribs(
                array(
                        "class" => "cssform"
                ));
        
        $champ = new Zend_Form_Element_Hidden("id");
        $champs[] = $champ;
        
        $champ = new Zend_Form_Element_Select("idRole");
        $champ->setLabel(__("Role"));
        $champ->setRequired(true);
        $champ->setMultiOptions($this->_roles);
        $champs[] = $champ;
        
        $champ = new Zend_Form_Element_Select("ressource");
        $champ->setLabel(__("Ressource"));
        $champ->setRequired(true);
        $champ->setMultiOptions($this->_ressources);
        $champs[] = $champ;
        
        $champ = new Zend_Form_Element_Checkbox("autorise");
        $champ->setLabel(__("Autorisé"));
        $champs[] = $champ;
        
        $champ = new Zend_Form_Element_Select("action");
        $champ->setLabel(__("Action"));
        $champ->setMultiOptions(array(
                "" => __('Choisir une ressource')
        ));
        $champ->setRegisterInArrayValidator(false);
        $champs[] = $champ;
        
        $this->addElements($champs);
    }
}

